package com.xmotor.testjavaxvalidation.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xmotor.testjavaxvalidation.validator.PlateType;
import lombok.Data;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Data
public class TestVO{

    @NotNull(message = "integer不能为空")
    @Min(message = "integer最小值为10",value = 10)
    @Max(message = "integer最大值为20",value = 20)
    private Integer integer;

    @NotBlank(message = "string不能为空")
    @Size(min = 3,max = 5,message = "string不在指定长度内")
    private String string;

    @NotBlank(message = "email不能为空")
    @Email(message = "email格式不正确")
    private String email;

    @NotBlank(message = "phone不能为空")
    @Pattern(regexp = "^[150[0-9]+]{11}",message = "phone格式不正确")
    private String phone;

    @NotNull(message = "bigDecimal不能为空")
    private BigDecimal bigDecimal;

    @NotNull(message = "localDateTime不能为空")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime localDateTime;

    @NotEmpty(message = "stringList不能为空")
    private List<String> stringList;

    @PlateType
    private String plateType;

    @Valid
    private InnerVO innerVO;

}
